﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using MacViet.DataBaseAPI;

public partial class Control_UCEdit : BaseUC
{
    protected void Page_Load(object sender, EventArgs e)
    {
       //Response.Write(getResource("String1"));
    }
    protected void changePass_ChangingPassword(object sender, LoginCancelEventArgs e)
    {
        
        e.Cancel = true;         
        SQLHelper help=new SQLHelper();
        string newpass=ucPassword.NewPassword;
        int userId = -1;
        ACCOUNTSDataAPI dal = new ACCOUNTSDataAPI();    
        if (Session["ACC_ID"] != null)
        {
            userId = Convert.ToInt32(Session["ACC_ID"]);
        }
               
        
        if (dal.updateAccountpass(userId, newpass,ucPassword.CurrentPassword))
        {
            ucPassword.InstructionText = "Password has been changed.";
            Session["password"] = help.GetEncryString(newpass);
        }
        else
        {
            ucPassword.InstructionText = "Old password is incorrect.";
        }
    }   
}
